package com.hong.springboot.config;


import org.openjdk.btrace.core.annotations.*;


import static org.openjdk.btrace.core.BTraceUtils.Strings.str;
import static org.openjdk.btrace.core.BTraceUtils.println;
import static org.openjdk.btrace.core.BTraceUtils.timeMillis;

/**
 * @author: csh
 * @Date: 2022/6/25 16:29
 * @Description:监控耗时
 */
@BTrace
public class TlsBtrace {

    @TLS
    private static long startTime = 0;

    @OnMethod(clazz = "com.hong.springboot.controller.IndexController", method="index1")
    public static void startMethod(){
        startTime = timeMillis();
    }

    @OnMethod(clazz = "com.hong.springboot.controller.IndexController", method="index1", location=@Location(Kind.RETURN))
    public static void endMethod(@ProbeClassName String pcm, @ProbeMethodName String pmn) {
        println(pcm + "." + pmn + " [Time taken: " + str(timeMillis() - startTime) + "ms]");
    }
    
    


}
